package com.von.platform.impl.service.rulecfg.ctrl;

import java.util.List;

import org.apache.log4j.Logger;

import com.von.platform.orm.IPersistenceManager;
import com.von.platform.orm.PersistenceManagerFactory;
import com.von.platform.orm.QueryCommand;
import com.von.platform.orm.TransactionException;
import com.von.platform.servic.IRuleConfig;
import com.von.platform.servic.IRuleConfigFinder;
import com.von.platform.servic.RuleException;

public class PdkRuleConfigController implements IRuleConfigFinder {
    private static final Logger logger = Logger.getLogger(PdkRuleConfigController.class);

    @SuppressWarnings("unchecked")
    @Override
    public List<? extends IRuleConfig> getRuleConfigs(String owner, String ruleId) throws RuleException {
        try {
            IPersistenceManager pm = PersistenceManagerFactory.getInstance().getCurrentPM();
            QueryCommand cmd = new QueryCommand();
            cmd.setName("PdkRuleConfig.getByOwnerAndRuleId");
            cmd.addParam(owner);
            cmd.addParam(ruleId);
            return (List<? extends IRuleConfig>) pm.query(cmd);
        } catch (TransactionException e) {
            logger.error("getRuleConfigs faile");
            throw new RuleException(e);
        }
        
    }

}
